package t20211225;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Author: DengJia
 * @Date: 2021/12/25 16:25
 * @Description: 统计元音字母的数量
 */

public class CountTheNumberOfVowels {
    private int counter = 0;

    int count(List<String> list) {
        for (String s : list) {
            switch (s) {
                case "a":
                case "e":
                case "i":
                case "o":
                case "u":
                case "A":
                case "E":
                case "I":
                case "O":
                case "U":
                    counter++;
            }
        }
        return counter;
    }

    public static void main(String[] args) {
        CountTheNumberOfVowels c = new CountTheNumberOfVowels();
        String[] ss = "Enter a string".split(" ");
        List<String> list = new ArrayList<>();

        for (String s : ss) {
            list.addAll(Arrays.asList(s.split("")));
        }
        System.out.println("c.count(list) = " + c.count(list));
    }
}
